<template>
	<!-- 修改密码 -->
	<view class="content">
		<view class="input-group">
			<view class="input-row">
				<text class="title">手机号:</text>
				<input class="input" maxlength="11" v-model="tel" type="text" placeholder="请输入手机号">
			</view>
		</view>

		<view class="btn-row">
			<button class="btn" @tap="findPassword">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tel:'',account:''
			}
		},
		onLoad(option) {
			this.account = option.account;
		},
		methods: {
			async findPassword() {
				var tel = this.tel.replace(/\s*/g,"")
				if (tel.replace(/\s*/g,"").length != 11) {
					uni.showToast({
						icon: 'none',
						title: '联系方式不符合规范',
					});
				} else {
					const res =await this.Request({
						url:'/api/super/pergetdata',
						method:'POST',
						data:{account:this.account}
					})
					if(this.tel == res.data[0].tel){
						uni.reLaunch({
							url:'/pages/super/sup-homepage/sup-changpass?account='+this.account
						})
					}else {
						uni.showToast({
							icon: 'error',
							title: '与预留联系方式不符，请重试',
						});
						this.tel = ''
					}
				}
			}
		}
	}
</script>

<style lang="scss">
	.content{
		.input-group{
			height: 60px;
			width: 100%;
			margin-top: 50px;
			.input-row{
				margin-left: 5%;
				width: 90%;
				height: 40px;
				margin-top: 10px;
				display: flex;
				border-radius: 5px;
				border: 1px solid #dadadd;
				background-color: #98d5c6;
				.title{
					margin: auto 0;
				}
				.input{
					margin: auto 0;
					margin-left: 15px;
				}
			}
		}
		.btn-row{
			margin-top: 20px;
			.btn{
				width: 90%;
				background-color: #ffa53d;
			}
		}
	}
</style>
